Update GUI to internal release 0.2.2.20.
authoroliskoli <oliskoli@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 6 Dec 2005 00:49:43 +0000 (00:49 +0000)
committeroliskoli <oliskoli@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 6 Dec 2005 00:49:43 +0000 (00:49 +0000)
gpsbabel/win32/gui-2/options.dfm
gpsbabel/win32/gui-2/options.pas

index 70f3a3ce8f2cb96a1e236c4a413aa66485d7731a..0fe28ae43b6d68a95066717430c7e491fe1436a2 100644 (file)
Binary files a/gpsbabel/win32/gui-2/options.dfm and b/gpsbabel/win32/gui-2/options.dfm differ
index eeb3fdc5cfcf5500cd2946580038aebb8d23dd4e..0cc5b071b4513f50b7b2f5c204be57e36412aae1 100644 (file)
@@ -24,7 +24,7 @@ uses
   TypInfo, gnugettext, gnugettextDx,\r
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,\r
   StdCtrls, ExtCtrls, ComCtrls, Buttons,\r
-  Common;\r
+  Common, delphi;\r
 \r
 type\r
   TfrmOptions = class(TForm)\r
@@ -78,6 +78,63 @@ uses
 \r
 {$R *.DFM}\r
 \r
+// returns "BottomRight" of Controls rect\r
+\r
+function SetCaption(Control: TControl; const ACaption: string): TPoint;\r
+var\r
+  s: TStaticText;\r
+  auto, info: PPropInfo;\r
+  font: TFont;\r
+  parentf: Boolean;\r
+begin\r
+  Result := Control.BoundsRect.BottomRight;\r
+\r
+  info := GetPropInfo(Control, 'Caption');\r
+  if (info = nil) then Exit;\r
+\r
+  SetStrProp(Control, 'Caption', ACaption);\r
+\r
+  auto := GetPropInfo(Control, 'AutoSize');\r
+  if (auto <> nil) then\r
+  begin\r
+    SetOrdProp(Control, auto, Integer(True));\r
+    Result := Control.BoundsRect.BottomRight;\r
+    Exit;\r
+  end;\r
+\r
+  info := GetPropInfo(Control, 'Font');\r
+  if (info = nil) then Exit;\r
+\r
+  font := Pointer(GetObjectProp(Control, info));\r
+\r
+  info := GetPropInfo(Control, 'ParentFont');\r
+  if (info <> nil) then\r
+    parentf := Boolean(GetOrdProp(Control, info)) else\r
+    parentf := False;\r
+\r
+// Controls with Caption but without AutoSize\r
+// TCheckBox, TRadioButton\r
+\r
+  s := TStaticText.Create(Control.Owner);\r
+  try\r
+    s.Font := font;\r
+    s.ParentFont := parentf;\r
+    s.Visible := False;\r
+    s.Parent := Control.Parent;\r
+    s.BoundsRect := Control.BoundsRect;\r
+    s.AutoSize := True;\r
+    s.Caption := ACaption;\r
+    Control.Width := 18 + s.Width;\r
+    if (Control.Height < s.Height) then\r
+      Control.Height := s.Height;\r
+    Result := Control.BoundsRect.BottomRight;\r
+  finally\r
+    s.Free;\r
+  end;\r
+end;\r
+\r
+{ TfrmOptions }\r
+\r
 constructor TfrmOptions.Create(AOwner: TComponent); // override;\r
 begin\r
   inherited Create(AOwner);\r
@@ -94,10 +151,12 @@ var
   wc: TControl;\r
   o: POption;\r
   chb: TCheckBox;\r
-  xy: TPoint;\r
+  xy, _xy: TPoint;\r
   xmax: Integer;\r
   lb: TLabel;\r
 begin\r
+  if (AList = nil) then Exit;\r
+  \r
   FOpts := AList;\r
 \r
   xy.x := 0;\r
@@ -134,23 +193,28 @@ begin
     InsertComponent(chb);\r
 \r
     chb.ParentFont := False;\r
-    chb.Font := Main.frmMain.stbMain.Font;\r
+    chb.Font := pnOptions.Font;\r
     chb.Left := 8;\r
     chb.Top := xy.y;\r
-    chb.Caption := dgettext('Options', o.Hint);\r
+    _xy := SetCaption(chb, dgettext(GPSBabel_Domain, o.Hint));\r
     chb.Alignment := taRightJustify;\r
     chb.Checked := False;\r
     chb.Parent := pnOptions;\r
 \r
     chb.Hint := SysUtils.Format(_('Short "%s"'), [o.name]);\r
     chb.ShowHint := True;\r
-    chb.Width := 21 + Trunc(FCanvas.TextWidth(chb.Caption) * 1.25);\r
 \r
     xy.y := xy.y + chb.Height + 8;\r
     if (o.otype <> 4) then\r
       if (chb.Width > xy.x) then xy.x := chb.Width;\r
     if (chb.Width > xy.x) then\r
       xmax := chb.Width;\r
+\r
+    if (o.otype = 4) and (o.def <> nil) and (atoi(o.def) <> 0) then\r
+    begin\r
+      chb.AllowGrayed := True;\r
+      chb.State := cbGrayed;\r
+    end;\r
   end;\r
 \r
   xy.y := 8;\r
@@ -174,7 +238,7 @@ begin
     end;\r
     if (o.edit <> nil) then\r
       o.edit.Enabled := False;\r
-    xy.y := xy.y + chb.Height + 8;\r
+    xy.y := xy.y + o.chb.Height + 8;\r
   end;\r
 \r
   xy.X := 0;\r
@@ -216,11 +280,26 @@ begin
   for i := 0 to FOpts.Count - 1 do\r
   begin\r
     o := Pointer(FOpts.Objects[i]);\r
-    if (o.chb = nil) or not(o.chb.Checked) then Continue;\r
+    if (o.chb = nil) then Continue;\r
+\r
+    if o.chb.AllowGrayed then\r
+    begin\r
+      if (o.chb.State = cbGrayed) then Continue\r
+    end\r
+    else if not(o.chb.Checked) then Continue;\r
+    \r
     if (Result <> '') then\r
       Result := Result + ',';\r
     Result := Result + o.name;\r
-    if (o.edit = nil) then Continue;\r
+\r
+    if (o.edit = nil) then\r
+    begin\r
+      if o.chb.Checked then\r
+        Result := Result + '=1'\r
+      else\r
+        Result := Result + '=0';\r
+      Continue;\r
+    end;\r
     s := GetStrProp(o.edit, 'Text');\r
     if (Pos(' ', s) <> 0) or (Pos('"', s) <> 0) or (Pos(',', s) <> 0) then\r
       s := SysUtils.AnsiQuotedStr(s, '"');\r